home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / pq / hpq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  1.6 KB  |  66 lines

  1. /*
  2.  * (c) Copyright 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef __HPQ_H
  8. #define __HPQ_H
  9.  
  10. /*
  11.  * $Id: hpq.h,v 1.2 1993/04/01 02:15:32 panos Exp $
  12.  */
  13.  
  14. /*
  15.  * Implementation of the PQ interface
  16.  */
  17.  
  18. #define pq_create                __hpq_create
  19. #define pq_destroy            __hpq_destroy
  20. #define pq_insert                __hpq_insert
  21. #define pq_delete                __hpq_delete
  22. #define pq_head                __hpq_head
  23. #define pq_extract_head        __hpq_extract_head
  24.  
  25. /*
  26.  * The is_better function takes 2 arguments which are pointers to objects
  27.  * and returns:
  28.  *       1     if the first object is "better" than the second
  29.  *       0     otherwise
  30.  */
  31.  
  32. struct __hpq_header
  33. {
  34.     int (*is_better)() ;
  35.     int *errnop ;
  36.     int flags ;
  37.     pq_obj *objects ;            /* array of objects */
  38.     unsigned cur_size ;        /* # of objects in array */
  39.     unsigned max_size ;        /* max # of objects that can fit in array */
  40. } ;
  41.  
  42.  
  43. #ifndef __ARGS
  44. #  ifdef PROTOTYPES
  45. #     define __ARGS( s )               s
  46. #  else
  47. #     define __ARGS( s )               ()
  48. #  endif
  49. #endif
  50.  
  51. pq_h __hpq_create            __ARGS( ( int (*func)(), int flags, int *errnop ) ) ;
  52. void __hpq_destroy        __ARGS( ( pq_h handle ) ) ;
  53. int  __hpq_insert            __ARGS( ( pq_h handle, pq_obj object ) ) ;
  54. pq_obj __hpq_extract_head __ARGS( ( pq_h handle ) ) ;
  55. int  __hpq_delete         __ARGS( ( pq_h handle, pq_obj object ) ) ;
  56.  
  57. #define __hpq_head( handle )                                                                \
  58.                 (                                                                                    \
  59.                     ((struct __hpq_header *)(handle))->cur_size                        \
  60.                             ? ((struct __hpq_header *)(handle))->objects[ 0 ]         \
  61.                             : (pq_obj) 0                                                        \
  62.                 )
  63.  
  64. #endif __HPQ_H
  65.  
  66.